home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_09_04
/
9n04120a
< prev
next >
Wrap
Text File
|
1990-12-29
|
1KB
|
38 lines
#include <stdio.h>
FILE *ofp;
void main( void ) {
double big, small;
float fbig, fsmall;
int flag[4], power;
ofp = fopen( "roundoff.out", "w" );
big = small = 1.0;
fbig = (float)big;
for( power = 1; power <= 50; power++ ) {
small *= 0.1;
fsmall = (float)small;
flag[0] = flag[1] = flag[2] = flag[3] = 1;
if( big+small == big )
flag[0] = 0;
if( (big+small) == big )
flag[1] = 0;
if( fbig+fsmall == fbig )
flag[2] = 0;
if( (fbig+fsmall) == fbig )
flag[3] = 0;
printf( "Power = %2d, Big+Small = %e, Flags = %d %d %d %d\n",
power, big+small, flag[0], flag[1], flag[2], flag[3] );
fprintf( ofp, "Power = %2d, Big+Small = %e, Flags = %d %d %d %d\n",
power, big+small, flag[0], flag[1], flag[2], flag[3] );
}
}